#!/usr/bin/env python
PACKAGE = "caros_camera"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

capture = gen.add_group('Capture')

pixel_format = gen.enum([ gen.const("BayerRG8", str_t, "BayerRG8", ""),
		                  gen.const("BayerBG8", str_t, "BayerBG8", ""),
                          gen.const("Mono8", str_t, "Mono8", "")],
                          "Pixel format")

capture.add("PixelFormat", str_t, 0, "Pixel format", "BayerBG8", edit_method=pixel_format)

exposure_auto = gen.enum([ gen.const("ExposureContinuous", str_t, "Continuous", ""),
                           gen.const("ExposureOnce", str_t, "Once", ""),
                           gen.const("ExposureOff", str_t, "Off", "")],
                           "Exposure setting")

capture.add("ExposureAuto", str_t, 0, "Exposure setting", "Continuous", edit_method=exposure_auto)

gain_auto = gen.enum([ gen.const("GainContinuous", str_t, "Continuous", ""),
                       gen.const("GainOnce", str_t, "Once", ""),
                       gen.const("GainOff", str_t, "Off", "")],
                       "Gain setting")

capture.add("GainAuto", str_t, 0, "Gain setting", "Continuous", edit_method=gain_auto)

capture.add('GainRaw',          int_t,    level=0, default=1,     min=1,    max=3,
            description="A positive integer specifying the gain factor.")

capture.add('ExposureTimeRaw',          int_t,    level=0, default=10000,     min=10,    max=916000,
            description="Sets the camera's exposure time in microseconds")

capture.add('BlackLevelRaw',  int_t,   level=0, default=0,   min=-128, max=127,
            description="This boolean value enables the gamma correction")

capture.add('GammaEnable',  bool_t,   level=0, default=False,
            description="This boolean value enables the gamma correction")

capture.add('Gamma',  double_t, level=0, default=1.0,   min=0.0, max=3.99999,
            description="Sets the 'absolute' value of the acquisition frame rate. The 'absolute' value is a float "
                        "value that sets the acquisition frame rate in frames per second.")

capture.add('AcquisitionFrameRateEnable',  bool_t,   level=0, default=True,
            description="This boolean value enables setting the camera's acquisition frame rate to a specified value.")

capture.add('AcquisitionFrameRateAbs',  double_t, level=0, default=10.0,   min=0.000466, max=1000.0,
            description="Sets the 'absolute' value of the acquisition frame rate. The 'absolute' value is a float "
                        "value that sets the acquisition frame rate in frames per second.")

balance_white_auto = gen.enum([ gen.const("BalanceWhiteContinuous", str_t, "Continuous", ""),
                                gen.const("BalanceWhiteOnce", str_t, "Once", ""),
                                gen.const("BalanceWhiteOff", str_t, "Off", "")],
                              "Balance white setting")

capture.add("BalanceWhiteAuto", str_t, 0, "Balance white setting", "Continuous", edit_method=balance_white_auto)

color_transformation_selector = gen.enum([ gen.const("ColorTransformationSelector_RGBtoRGB", str_t, "RGBtoRGB", ""),
                                gen.const("ColorTransformationSelector_RGBtoYUV", str_t, "RGBtoYUV", ""),
                                gen.const("ColorTransformationSelector_YUVtoRGB", str_t, "YUVtoRGB", "")],
                              "This parameter is used to select the type of transformation that will be performed before color "
                              "correction for a specific light source is performed.")

capture.add("ColorTransformationSelector", str_t, 0, "This parameter is used to select the type of transformation that will be performed before color "
                                                     "correction for a specific light source is performed.", "RGBtoRGB", edit_method=color_transformation_selector)

capture.add('ColorTransformationMatrixFactorRaw',  int_t,   level=0, default=65536,   min=0, max=65536,
            description="Sets an integer value to define the extent to which the selected light source will be "
                        "considered in color matrix transformation. If the value is set to 65536 the selected light "
                        "source will be fully considered. If the value is set to 0 the selected light source will not "
                        "be considered.")

light_source_selector = gen.enum([  gen.const("LightSourceSelector_Off", str_t, "Off", ""),
                                    gen.const("LightSourceSelector_Custom", str_t, "Custom", ""),
                                    gen.const("LightSourceSelector_Daylight", str_t, "Daylight", ""),
                                    gen.const("LightSourceSelector_Tungsten", str_t, "Tungsten", ""),
                                    gen.const("LightSourceSelector_Daylight6500K", str_t, "Daylight6500K", ""),
                                    gen.const("LightSourceSelector_LightSource0", str_t, "LightSource0", ""),
                                    gen.const("LightSourceSelector_LightSource1", str_t, "LightSource1", "")],
                                         "Selects the light source")

capture.add("LightSourceSelector", str_t, 0, "Selects the light source", "Daylight", edit_method=light_source_selector)

capture.add('ColorAdjustmentEnable',  bool_t,   level=0, default=False, description="Enables color adjustment")

capture.add('ColorBalanceValueRed',  int_t,   level=0, default=72,   min=0, max=255, description="Sets the red color balance as an integer")
capture.add('ColorBalanceValueGreen',  int_t,   level=0, default=64,   min=0, max=255, description="Sets the green color balance as an integer")
capture.add('ColorBalanceValueBlue',  int_t,   level=0, default=130,   min=0, max=255, description="Sets the blue color balance as an integer")

aoi_controls = gen.add_group('AOI Controls')

aoi_controls.add('Width',          int_t,    level=0, default=2592,     min=16,    max=2592,
            description="This value sets the width of the area of interest in pixels.")
aoi_controls.add('Height',          int_t,    level=0, default=2048,     min=1,    max=2048,
            description="This value sets the height of the area of interest in pixels.")
aoi_controls.add('AutoFunctionAOIWidth',          int_t,    level=0, default=2592,     min=1,    max=2592,
                 description="This value sets the width of the auto function area of interest in pixels.")
aoi_controls.add('AutoFunctionAOIHeight',          int_t,    level=0, default=2048,     min=1,    max=2048,
                 description="This value sets the height of the auto function area of interest in pixels.")

transmission = gen.add_group('Transmission')

transmission.add("GevSCPSPacketSize", str_t, level=0, default="8192", description="Sets the packet size, must match the Maximum Transfer Unit (MTU) configured for the Network Adapter")
transmission.add("GevSCPD", str_t, level=0, default="10000", description="Sets the (Inter packet delay), increase this, if experiencing transmission errors")

exit(gen.generate(PACKAGE, "caros_camera", "Basler"))
